package com.dongdongshop.controller;

import com.dongdongshop.service.ItemPageService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RocketMQMessageListener(topic = "item-goods",consumerGroup = "item_goods_ids")//149187842867946
public class ItemPageController implements RocketMQListener<Long[]> {

    @Autowired
    private ItemPageService itemPageService;

    @RequestMapping("itemPage")
    @ResponseBody
    public String itemPage(Long goodsId){
        itemPageService.itemPage(goodsId);
        return "ok";
    }

    @Override
    public void onMessage(Long[] longs) {
        for (Long aLong : longs) {
            itemPageService.itemPage(aLong);
        }
    }
}
